varying vec3 normal, lightVec, viewerVec;

void main() {

	vec4 I, Ia, Id, Is;
	vec3 n, lv, rv, vv, halfV;
	float NdotL, RdotV, power;

	I = vec4( 0.0, 0.0, 0.0, 0.0 );

	n = normalize( normal );
	lv = normalize( lightVec );
	vv = normalize( viewerVec );

	NdotL = dot( n, lv );

	rv = normalize( 2.0 * NdotL * n - lv );

	RdotV = dot( rv, vv );
	RdotV = max( RdotV, 0.0 );
	power = pow( RdotV, /*gl_FrontMaterial.shininess*/ 2.0 ) ;

	Ia = gl_LightSource[0].ambient * gl_FrontMaterial.ambient;
	Id = gl_LightSource[0].diffuse * gl_FrontMaterial.diffuse * max( NdotL, 0.0 ) ;
	Is = gl_LightSource[0].specular * gl_FrontMaterial.specular * power;

	I += Ia;
	I += Id;
	I += Is;

	gl_FragColor = I;
}	